﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Restaurant.DTO;
using Restaurant.BUS;

namespace Restaurant
{
    public partial class frmHoaDon : Form
    {
        private HoaDonService hdService = new HoaDonService();

        public frmHoaDon()
        {
            InitializeComponent();
        }
        int MaNH;
        DateTime Ngay;

        public void LoadHoaDonBan(DataTable dbtab)
        {
            for (int i = 0; i < dbtab.Rows.Count; i++)
            {
                DataRow dbrow = dbtab.Rows[i];
                ListViewItem liv = new ListViewItem();
                liv.Text = dbrow["MaHDB"].ToString();
                liv.SubItems.Add(dbrow["TenKH"].ToString());
                liv.SubItems.Add(dbrow["TenNH"].ToString());
                liv.SubItems.Add(dbrow["NgayLapHD"].ToString());
                liv.SubItems.Add(dbrow["ThanhTien"].ToString());
                lvDanhSachHoaDon.Items.Add(liv);
            }
        }

        public frmHoaDon(int maNH, DateTime ngay)
        {
            MaNH = maNH;
            Ngay = ngay;
            InitializeComponent();
        }
        private void btnTroVe_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmHoaDon_Load(object sender, EventArgs e)
        {
            DataTable hdbdtb = hdService.LoadHoaDonTheoNgayNH(MaNH, Ngay);
            LoadHoaDonBan(hdbdtb);
        }
    }
}
